package v1

import (
	"devops-super/api"
	"devops-super/internal/model/entity"
	"github.com/gogf/gf/v2/frame/g"
)

// DeviceGroupConfigGetPageLstReq 分页获取设备分组配置列表请求
type DeviceGroupConfigGetPageLstReq struct {
	g.Meta `method:"get" path:"/device-group-config/page-list" summary:"分页获取设备分组配置列表" tags:"设备分组配置"`
	*api.PageLstReq
}

// DeviceGroupConfigGetPageLstRes 分页获取设备分组配置列表响应
type DeviceGroupConfigGetPageLstRes struct {
	*api.PageLstRes[*entity.AppDeviceGroupConfig]
}

// DeviceGroupConfigAddReq 新增设备分组配置请求
type DeviceGroupConfigAddReq struct {
	g.Meta        `method:"post" path:"/device-group-config" summary:"新增设备分组配置" tags:"设备分组配置"`
	DeviceGroupId int64  `v:"required#设备分组ID不能为空" json:"deviceGroupId"`
	GroupName     string `v:"required#配置组名不能为空" json:"groupName"`
	ConfigKey     string `v:"required#配置键不能为空" json:"configKey"`
	ConfigValue   string `v:"required#配置值不能为空" json:"configValue"`
	Remark        string `json:"remark"`
	Range         int    `v:"required#作用范围必须" json:"range"` // 0:仅自己, 1:自己及子类
}

// DeviceGroupConfigAddRes 新增设备分组配置响应
type DeviceGroupConfigAddRes struct {}

// DeviceGroupConfigUptReq 更新设备分组配置请求
type DeviceGroupConfigUptReq struct {
	g.Meta        `method:"put" path:"/device-group-config/{id}" summary:"更新设备分组配置" tags:"设备分组配置"`
	Id            int64  `v:"min:1#配置ID必须" path:"id"`
	DeviceGroupId int64  `v:"required#设备分组ID不能为空" json:"deviceGroupId"`
	GroupName     string `v:"required#配置组名不能为空" json:"groupName"`
	ConfigKey     string `v:"required#配置键不能为空" json:"configKey"`
	ConfigValue   string `v:"required#配置值不能为空" json:"configValue"`
	Remark        string `json:"remark"`
	Range         int    `v:"required#作用范围必须" json:"range"` // 0:仅自己, 1:自己及子类
}

// DeviceGroupConfigUptRes 更新设备分组配置响应
type DeviceGroupConfigUptRes struct {}

// DeviceGroupConfigDelReq 删除设备分组配置请求
type DeviceGroupConfigDelReq struct {
	g.Meta `method:"delete" path:"/device-group-config/{id}" summary:"删除设备分组配置" tags:"设备分组配置"`
	Id     int `v:"min:1#配置ID必须" path:"id"`
}

// DeviceGroupConfigDelRes 删除设备分组配置响应
type DeviceGroupConfigDelRes struct {}

// DeviceGroupConfigGetOneReq 获取单条设备分组配置请求
type DeviceGroupConfigGetOneReq struct {
	g.Meta `method:"get" path:"/device-group-config/getOne" summary:"获取单条设备分组配置" tags:"设备分组配置"`
	Id     int `v:"min:1#配置ID必须" json:"id"`
}

// DeviceGroupConfigGetOneRes 获取单条设备分组配置响应
type DeviceGroupConfigGetOneRes struct {
	Info *entity.AppDeviceGroupConfig `json:"info"`
}

// DeviceGroupConfigGetOptionsReq 获取设备分组配置选项请求
type DeviceGroupConfigGetOptionsReq struct {
	g.Meta        `method:"get" path:"/device-group-config/getOptions" summary:"获取设备分组配置选项" tags:"设备分组配置"`
	FieldKey      string `json:"fieldKey"`      // 自定义value字段
	FieldLabel    string `json:"fieldLabel"`    // 自定义label字段
	DeviceGroupId int64  `json:"deviceGroupId"` // 按设备分组ID筛选
	GroupName     string `json:"groupName"`     // 按配置组名筛选
}

// DeviceGroupConfigGetOptionsRes 获取设备分组配置选项响应
type DeviceGroupConfigGetOptionsRes struct {
	Options []*api.FormOptionsItem `json:"options"`
}

// GetDeviceGroupGroupConfigsReq 获取设备分组配置组请求
type GetDeviceGroupGroupConfigsReq struct {
	g.Meta        `method:"get" path:"/device-group-config/get-device-group-group-configs" summary:"获取设备分组配置组" tags:"设备分组配置"`
	DeviceGroupId int64  `v:"min:1#设备分组ID必须" json:"deviceGroupId" in:"query"`
	GroupName     string `v:"required#配置组名必须" json:"groupName" in:"query"`
}

// GetDeviceGroupGroupConfigsRes 获取设备分组配置组响应
type GetDeviceGroupGroupConfigsRes struct {
	Configs   []*entity.AppDeviceGroupConfig `json:"configs"`
	UpdatedAt string                         `json:"updatedAt"`
}

// SetDeviceGroupGroupConfigsReq 设置设备分组配置组请求
type SetDeviceGroupGroupConfigsReq struct {
	g.Meta        `method:"post" path:"/device-group-config/set-device-group-group-configs" summary:"保存设备分组配置组" tags:"设备分组配置"`
	DeviceGroupId int64  `v:"min:1#设备分组ID必须" json:"deviceGroupId"`
	GroupName     string `v:"required#配置组名必须" json:"groupName"`
	Configs       []struct {
		ConfigKey   string `v:"required#配置键必须" json:"configKey"`
		ConfigValue string `v:"required#配置值必须" json:"configValue"`
		ConfigDesc  string `json:"configDesc"`
	} `v:"required#配置项不能为空" json:"configs"`
}

// SetDeviceGroupGroupConfigsRes 设置设备分组配置组响应
type SetDeviceGroupGroupConfigsRes struct {}
